package com.tarena.lbs.content.controller;

import com.tarena.lbs.base.protocol.model.Result;
import com.tarena.lbs.base.protocol.pager.PageResult;
import com.tarena.lbs.content.pojo.param.ArticleCategoryParam;
import com.tarena.lbs.content.pojo.vo.ArticleCategoryVO;
import com.tarena.lbs.content.service.CategoryService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 处理文章分类 业务模块功能
 */
@Tag(name = "文章分类管理")
@RestController
@RequiredArgsConstructor
public class CategoryController {
    private final CategoryService categoryService;
    @Operation(summary = "新增文章分类")
    @PostMapping("/admin/content/category/insert")
    public Result<Void> addCategory(ArticleCategoryParam param){
        categoryService.saveArticleCategory(param);
        return Result.success();
    }
    @Operation(summary = "编辑文章分类")
    @PostMapping("/admin/content/category/update")
    public Result<Void> updateCategory(ArticleCategoryParam param){
        categoryService.saveArticleCategory(param);
        return Result.success();
    }
    @Operation(summary = "文章分类列表查询")
    @GetMapping("/admin/content/category/list")
    public Result<PageResult<ArticleCategoryVO>> pageList(){
        return new Result<>(categoryService.listAllArticleCategory());
    }
}
